﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PHTShop.admin
{
    public partial class editPartner : System.Web.UI.Page
    {
        private DataContextDataContext dc = new DataContextDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Edit partner";
            if (!IsPostBack)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                var partner = dc.Partners.SingleOrDefault(z=>z.id==id);
                TextboxPartnerName.Value = partner.name;
                TextboxDescription.Value = partner.details;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                var partner = dc.Partners.SingleOrDefault(z=>z.id==id);
                partner.name = TextboxPartnerName.Value;
                partner.details = TextboxDescription.Value;
                dc.SubmitChanges();
                Response.Redirect("createPartner.aspx");
            }
        }
    }
}